package com.davies.learn.feature;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.function.Consumer;

/**
 * @author davies
 * @date 2023/7/26 02:28
 */
public class Car {


    Consumer<LocalDateTime> consumer;

    /**
     * 注册订阅者
     * @param consumer
     */
    public void register(Consumer<LocalDateTime> consumer) {
        if (this.consumer == null) {
            this.consumer = consumer;
        }else{
            this.consumer = this.consumer.andThen(consumer);
        }
    }




    public void start(){
        if (this.consumer!=null) {
            //订阅者方法
            this.consumer.accept(LocalDateTime.now());
        }
        System.out.println("王总走了");

    }
}
